//
//  UINavHeadView.m
//  RM_IM
//
//  Created by user1 on 2018/6/20.
//  Copyright © 2018年 user1. All rights reserved.
//

#import "UINavHeadView.h"

@interface UINavHeadView()

@property (nonatomic ,strong)UILabel *titleLabel;

@property (nonatomic ,strong)UIImageView *imv;

@property (nonatomic ,strong)UIView *sepView;

@end

@implementation UINavHeadView

- (instancetype)init
{
    self = [super init];
    if (self) {
        [self initView];
    }
    return self;
}

- (void)initView{
    [self addSubview:self.titleLabel];
    [self addSubview:self.imv];
    [self addSubview:self.sepView];
}

- (void)initNavigationViewWithTitle:(NSString *)title isShowRight:(BOOL)isShow{
    if (isShow) {
        _imv.hidden = NO;
    }
    _titleLabel.text = title;
}

#pragma mark - event
- (void)clickAction:(UITapGestureRecognizer *)tap{
    if (self.navBlovk) {
        self.navBlovk();
    }
}


#pragma mark - 懒加载
- (UILabel *)titleLabel{
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc]init];
        _titleLabel.frame = CGRectMake(Fix375(15), Fix375(46), Fix375(60), Fix375(24));
        _titleLabel.textAlignment = NSTextAlignmentLeft;
        _titleLabel.font = RMSemFont(24);
        _titleLabel.textColor = UIColorFromRGB(0x333333);
    }
    return _titleLabel;
}

- (UIImageView *)imv{
    if (!_imv) {
        UIImage *image = [UIImage imageNamed:@"home_more"];
        _imv = [[UIImageView alloc]init];
        _imv.frame = CGRectMake(SCREEN_WIDTH - Fix375(15) - image.size.width, Fix375(49), image.size.width, image.size.height);
        _imv.userInteractionEnabled = YES;
        _imv.image = image;
        _imv.hidden = YES;
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickAction:)];
        [_imv addGestureRecognizer:tap];
    }
    return _imv;
}

- (UIView *)sepView{
    if (!_sepView) {
        _sepView = [[UIView alloc]init];
        _sepView.frame = CGRectMake(0, Fix375(79), SCREEN_WIDTH, Fix375(1));
        _sepView.backgroundColor = UIColorFromRGB(0xF3F3F3);
    }
    return _sepView;
}

@end
